/*  1:   */ package org.intellij.images.editor.actionSystem;
/*  2:   */ 
/*  3:   */

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.fileEditor.FileEditor;
import org.intellij.images.editor.ImageEditor;
import org.intellij.images.editor.ImageFileEditor;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */ 
/* 12:   */ public final class ImageEditorActionUtil
/* 13:   */ {
/* 14:   */   public static ImageEditor getValidEditor(AnActionEvent paramAnActionEvent)
/* 15:   */   {
/* 16:42 */     ImageEditor localImageEditor = getEditor(paramAnActionEvent);
/* 17:43 */     if ((localImageEditor != null) && (localImageEditor.isValid())) {
/* 18:44 */       return localImageEditor;
/* 19:   */     }
/* 20:46 */     return null;
/* 21:   */   }
/* 22:   */   
/* 23:   */   public static ImageEditor getEditor(AnActionEvent paramAnActionEvent)
/* 24:   */   {
/* 25:50 */     DataContext localDataContext = paramAnActionEvent.getDataContext();
/* 26:51 */     FileEditor localFileEditor = (FileEditor)PlatformDataKeys.FILE_EDITOR.getData(localDataContext);
/* 27:52 */     if ((localFileEditor instanceof ImageFileEditor))
/* 28:   */     {
/* 29:53 */       ImageFileEditor localImageFileEditor = (ImageFileEditor)localFileEditor;
/* 30:54 */       return localImageFileEditor.getImageEditor();
/* 31:   */     }
/* 32:56 */     return null;
/* 33:   */   }
/* 34:   */   
/* 35:   */   public static boolean setEnabled(AnActionEvent paramAnActionEvent)
/* 36:   */   {
/* 37:66 */     ImageEditor localImageEditor = getValidEditor(paramAnActionEvent);
/* 38:67 */     Presentation localPresentation = paramAnActionEvent.getPresentation();
/* 39:68 */     localPresentation.setEnabled(localImageEditor != null);
/* 40:69 */     return localPresentation.isEnabled();
/* 41:   */   }
/* 42:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.images.editor.actionSystem.ImageEditorActionUtil

 * JD-Core Version:    0.7.0.1

 */